<!--
 * @Author: zhanwei xu
 * @Date: 2023-08-19 17:30:45
 * @LastEditors: zhanwei xu
 * @LastEditTime: 2024-02-18 23:08:46
 * @Description: 
 * 
 * Copyright (c) 2024 by zhanwei xu, Tsinghua University, All Rights Reserved. 
-->
<script lang='ts' setup>
import { appRef } from '@/models/app.ref';
import { Message } from '@arco-design/web-vue';
import { onMounted, ref } from 'vue';
import Theme from './Theme.vue';
import { Site } from '@/config/base';
import { ThemeEnum } from '@/models/app.context';
import { getLocalStorageUseSize } from '@/utils/common.methods';

const openai_key = ref('');

onMounted(() => {
  openai_key.value = appRef.user.data.openai_key
})

function blurOpenai(): void {
  appRef.user.setOpenKey(openai_key.value);
  Message.success('Api_Key 全局设置成功')
}

function onClear(): void {
  localStorage.clear();
  Message.success('缓存清除成功');
}
</script>
<template>
  <div class="setting">
    <div class="group">
      <a href="https://gitee.com/xu-zhanwei/chatanywhere/blob/master/Support.md" target="_blank">
        <div class="cell flex"> <icon-face-smile-fill class="icon" /> 点击此处支持项目后续开发 </div>
      </a>
      <!-- <a :href="Site.oldwebsite" target="_black">
        <div class="cell flex"> <icon-schedule class="icon" /> 体验旧版 </div>
      </a> -->
      <div class="cell">
        <p class="title flex" style="margin-bottom: 10px;"><icon-idcard class="icon" />Api_Key</p>
        <a-input placeholder="输入卡密" allow-clear v-model="openai_key" @blur="blurOpenai" />
      </div>
      <a href="https://gitee.com/xu-zhanwei/chatanywhere/blob/master/4.md" target="_blank">
        <div class="cell flex"> <icon-face-smile-fill class="icon" /> 卡密获取说明与余额查询 </div>
      </a>
    </div>

  </div>
</template>
<style lang='scss' scoped>
.tip {
  width: 100%;
  padding: 7px;
  color: rgb(var(--arcoblue-7));
  opacity: .7;
  text-decoration: none;
  text-align: center;
  background: var(--color-neutral-4);
  justify-content: center;

  span {
    margin: 0 10px;
  }
}

.setting {
  .group {
    .cell {
      margin: 17px 0;
      border: 1px solid var(--color-border-3);
      padding: 17px 20px;
      border-radius: 3px;
    }

    .icon {
      margin-right: 10px;
      font-size: 20px;
    }
  }
}
</style>
